package com.nbsaas.boot.store.rest.convert;

import com.nbsaas.boot.store.data.entity.Store;
import com.nbsaas.boot.store.api.domain.response.StoreResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* -实体对象转化成响应对象
*/

public class StoreResponseConvert  implements Converter<StoreResponse,Store> {

    @Override
    public StoreResponse convert(Store source) {
        StoreResponse  result = new  StoreResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getShop()!=null){
                        result.setShop(source.getShop().getId());
                    }

                    try {
                        if(source.getShop()!=null){
                            result.setShopName(source.getShop().getName());
                        }
                    } catch (Exception ignored) { }


                    try {
                        if(source.getStoreCatalog()!=null){
                            result.setStoreCatalogName(source.getStoreCatalog().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getStoreStatus()!=null){
                        result.setStoreStatusName(String.valueOf(source.getStoreStatus()));
                    }
                    if(source.getStoreCatalog()!=null){
                        result.setStoreCatalog(source.getStoreCatalog().getId());
                    }
                    if(source.getAccount()!=null){
                        result.setAccount(source.getAccount().getId());
                    }

                    try {
                        if(source.getAccount()!=null){
                            result.setAccountAmount(source.getAccount().getAmount());
                        }
                    } catch (Exception ignored) { }

        return result;
    }

}

